﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace SaintchadEmailOrganizer
{
	public partial class EmailStatistics : UserControl
	{
		private List<Outlook.MailItem> emails;

		public EmailStatistics()
		{
			InitializeComponent();
		}

		private void chrtEmailStats_MouseClick(object sender, MouseEventArgs e)
		{
			if (e.Button == MouseButtons.Left)
			{
				//Context menu
				HitTestResult result = chrtEmailStats.HitTest(e.X, e.Y);

				if (result.ChartElementType == ChartElementType.DataPoint)
				{
					//Create Dialog
					cmnuChartBar.Show(e.X, e.Y);


				}
				
			}
		}

		private void ReadEmail()
		{

			Outlook.Explorer exp = Globals.ThisAddIn.Application.ActiveExplorer();
			Outlook.MAPIFolder currentFolder = exp.CurrentFolder;
			ReadEmail(currentFolder);
		}

		private void ReadEmail(Outlook.MAPIFolder folderName)
		{
			emails = new List<Outlook.MailItem>();

			foreach (object folderItem in folderName.Items)
			{
				Outlook.MailItem email = (Outlook.MailItem)folderItem;
				emails.Add(email);
			}

		}

		private void EmailStatistics_Load(object sender, EventArgs e)
		{
			//Category
			//Date
			//Flag
			//Sender
			//Subject

			string GroupBy = cboGroupBy.SelectedValue.ToString();
			switch (GroupBy)
			{
				case "Category":
					break;
				case "Date":
					break;
				case "Flag":
					break;
				case "Sender":
					var emails= from email in emails
								select 
					break;
				case "Subject":
					break;
			}
			
 



		}
	}
}
